package com.example.swagger.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version v1.0.0
 * @date 2019-06-10 20:31
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2019-06-10
 * @modify reason: {方法名}:{原因}
 * ...
 */
@AllArgsConstructor
@Getter
public enum SwaggerResourceEnum {
    /**
     * Swagger资源类型 URL
     */
    SWAGGER_RESOURCE_URL("url","api-docs-url"),
    /**
     * Swagger资源类型 json
     */
    SWAGGER_RESOURCE_JSON("json","json-path");

    private String type;

    private String key;

    public static SwaggerResourceEnum valueOfType( String key){
        List<SwaggerResourceEnum> collect = Arrays.stream(SwaggerResourceEnum.values()).filter(p -> p.getType().equals(key)).collect(Collectors.toList());
        return CollectionUtils.isEmpty(collect) ? null : collect.get(0);
    }
}
